use std::{io::Result, fs::File};
use retsu_rs::{
    chunker::fastcdc::{ConstConfig, StatefulConstConfWithFastFp},
    sync_chunk::exhaust_refill::SyncChunk,
};

fn main() -> Result<()> {
    let file_name = include_str!("../tmp-test-file.name").trim();
    let f = File::open(file_name)?;
    let size = f.metadata()?.len();

    let chunker = StatefulConstConfWithFastFp::new(ConstConfig::<2048, 65536, 8192, 1>::new());
    let mut ck = SyncChunk::<65536, _, _>::new(f, chunker);

    let mut n = 0;
    let mut combined: u64 = 0;
    while let Some((chunk, (wfp, cfp))) = ck.chunk_next()? {
        combined += cfp;
        n += 1;
    }
    println!(
        "Avg chunk size: {size}/{n}={}\nffp: {combined}",
        size as f64 / n as f64,
    );
    Ok(())
}
